Learning Flex Basics (Part 1): Creating Your First Flex Application
Table of Contents
- Introduction
- A Brief Overview of Macromedia Flex
- Building the Application
- Create the Application Object
- Add a Panel for the Application Layout
- Add a Label for the View Header
- Add an Array of Objects to Define the Coffee Blends
- Add a ComboBox to Display the Coffee Blends
- Add a Text Control to Display the Description
- Add a Button to Add a Coffee Blend to the Shopping Cart
- Add a List Control for the Shopping Cart
- Add a Script to Handle the Button Click Event
- Complete Code Listing for firstapp.mxml
- Where to Go From Here
Add a Button to Add a Coffee Blend to the Shopping Cart
The Button control is straightforward. It has a label property
for the text label to display. It also has a click event set equal
to an ActionScript expression or event-handler that will execute when the
user clicks the button.
In this case, you add a Button that adds the selected item in the ComboBox
to a simple cart by using the click event to call a function called addToCart(). You create this
function and the cart in later steps.
-
After the Text control, add a Button with a label that says "Add to Cart" and click event that calls an
addToCart()function:<mx:Button label="Add to Cart" click="addToCart()"/>